//package com.study.command;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.web.client.RestTemplate;
//
//import com.netflix.hystrix.HystrixCommandGroupKey;
//import com.netflix.hystrix.HystrixObservableCommand;
//import com.study.dao.entity.MovieUser;
//
//import rx.Observable;
//import rx.Observable.OnSubscribe;
//import rx.Subscriber;
///**
// * 通过继承的方式来实现
// *
// */
//@Service
//public class UserObservableCommand extends HystrixObservableCommand<MovieUser>{
//	
//	protected UserObservableCommand() {
//		super(HystrixCommandGroupKey.Factory.asKey("group")); //必须
//	}
//
//	@Autowired
//	RestTemplate restTemplate;
//
//	@SuppressWarnings("deprecation")
//	@Override
//	protected Observable<MovieUser> construct() {
////		return Observable.create(new OnSubscribe<MovieUser>() {
//		return Observable.create(new Observable.OnSubscribe<MovieUser>() {
//
//			@Override
//			public void call(Subscriber<? super MovieUser> observer) {
//				try {
//					if (!observer.isUnsubscribed()) {
//						
//						MovieUser movieUser = restTemplate.getForObject("http://sunxj-microservice-provider-user/simple/1", MovieUser.class);
//						observer.onNext(movieUser);
//						observer.onCompleted();
//					}
//				} catch (Exception e) {
//					observer.onError(e);
//				}
//				
//			}
//		});
//	}
//	
//	
//	public static void main(String[] args) throws Exception {
//	}
//
//}
